/*
 * Copyright (c) 2017, Li Bo/Alex Lee All rights reserved.
 * 
 * http://www.libo4dream.club/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
package com.hyts.fscan.validate;

import com.hyts.fscan.domain.Directory;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * @ClassName: DirectoryRuleValidate
 * @Description: 目录服务属性操作校验器
 * @author: LiBo/Alex Lee
 * @date: 2017年9月27日 上午1:23:33
 * @email: alexlibochn@china-pui.com.cn/alex.link@foxmail.com
 */
public class DirectoryRuleValidate {

	/**
	 * @Title: valiate
	 * @Description: 校验服务目录
	 * @param directory
	 * @return
	 * @return: boolean
	 */
	public static boolean valiateDirectory(Directory directory){
		//校验服务参数
		if(directory == null || 
				StringUtils.isEmpty(directory.getDirectoryPath())){
			return false;
		}
		return true;
	}
	
	
	/**
	 * @Title: isContainsExtName
	 * @Description: 是否包含扩展名
	 * @param fileName
	 * @return
	 * @return: boolean
	 */
	public static boolean isContainsExtName(String fileName,List<String> extNames){
		//扩展名
		if(StringUtils.isEmpty(fileName) || extNames == null || extNames.isEmpty()){
			return false;
		}
		else if(extNames.contains(fileName)){
			return true;
		}
		return false;
	}
	
	/**
	 * @Title: isContainsName
	 * @Description: 是否包含名
	 * @param fileName
	 * @return
	 * @return: boolean
	 */
	public static boolean isContainsName(String fileName,List<String> names){
		//扩展名
		if(StringUtils.isEmpty(fileName) || names == null || names.isEmpty()){
			return false;
		}
		else if(names.contains(fileName)){
			return true;
		}
		return false;
	}
	
	
}
